%function out = getMomentsData(setupStep3,outputStep3,thresholdLevel,econAct)
function out = getMomentsData(loadData,outputStep3,thresholdLevel)


econAct = loadData.econ;
h_index = [1,3,6,9,12,15,18,21,24];
for i=1:length(h_index)
    shortRateOneYear  = loadData.yields_h1(2:end,loadData.yields_h1(1,:)==12);
    startIdx          = h_index(1,i);
    endIdx            = max(outputStep3.model.matSelect);
    maturities        = loadData.yields_h1(1    ,1+(startIdx:h_index(1,i):endIdx));
    yields            = loadData.yields_h1(2:end,1+(startIdx:h_index(1,i):endIdx));   
    %maturities        = loadData.yields_h1(1    ,1+(startIdx:1:endIdx));
    %yields            = loadData.yields_h1(2:end,1+(startIdx:1:endIdx));   

    if h_index(1,i) == 1
        % CRSP yield for h = 1
        shortRate   = [loadData.crspRiskFree_h1(2:end,1);nan];
    elseif h_index(1,i) == 3
        % CRSP yield for h = 3
        shortRate = [loadData.crspRiskFree_h3(2:end,1);nan];
    else
        % GSW yield when h = 6 or higher
        shortRate = yields(:,1);
    end
   
    % Moments for model evaluations
    tmp = ['h',num2str(h_index(1,i))];
    bootOn = 1;
    out.(tmp) = momentsModelEval(yields,shortRate,shortRateOneYear,econAct,...
        loadData.ygap,thresholdLevel,maturities,h_index(1,i),bootOn);
    
end


% The LPYII tests
if isfield(outputStep3,'yieldTP')
    h_index = 12;
    maturities     = loadData.yields_h1(1,1+(h_index:h_index:endIdx));
    yields         = loadData.yields_h1(2:end,1+(h_index:h_index:endIdx));  
    out.LPYII      = CampbellSchillerRegression(yields,yields(:,1),outputStep3.yieldTP.termPremia(maturities,:)'/10000,...
                        outputStep3.yieldTP.forwardPermia(maturities,:)'/10000,maturities,h_index);
                    
end
end